package com.ochnas.volunteersignup.ui;

import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.Date;
import java.util.regex.Pattern;

import com.ochnas.volunteersignup.domain.Event;
import com.ochnas.volunteersignup.domain.Position;
import com.ochnas.volunteersignup.domain.Time;
import com.ochnas.volunteersignup.domain.TimeSlot;

public interface SharedConstants {
	public static final Pattern EMAIL_ADDRESS_PATTERN = Pattern.compile("[^\\s@]+[@{1}+][^\\s@]+");
	public static final Pattern PASSWORD_PATTERN = Pattern.compile("[^\\s]{6,12}");
	public static final Pattern PHONE_NUMBER_PATTERN = Pattern.compile("[\\d]{10}+");
	public static final SimpleDateFormat SIMPLE_DATE_TIME_FORMAT = new SimpleDateFormat("MM/dd/yyyy hh:mm a z");
	public static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("MM/dd/yyyy");
	public static final SimpleDateFormat SIMPLE_TIME_FORMAT = new SimpleDateFormat("hh:mm a");
	public static final Pattern SIMPLE_TIME_PATTERN = Pattern.compile("[\\d]{1,2}:[\\d]{2} [apAP]{1}[mM]{1}"); 
	public static final SimpleDateFormat SIMPLE_TIME_ZONE_FORMAT = new SimpleDateFormat("z");
	public static final String AM = "AM";
	public static final String PM = "PM";
	public static final Comparator<Event> SORT_BY_ASCENDING_DATE = new Comparator<Event>() {
		@Override
		public int compare(Event e1, Event e2) {
			Date e1StartDate = e1.getStartDate();
			Date e2StartDate = e2.getStartDate();
			if (e1StartDate.before(e2StartDate)) {
				return -1;
			} else if (e1StartDate.after(e2StartDate)) {
				return 1;
			} else {
				String e1Name = e1.getName();
				String e2Name = e2.getName();
				return e1Name.compareTo(e2Name);
			}
		}
		
	};
	public static final Comparator<TimeSlot> SORT_BY_ASCENDING_TIME = new Comparator<TimeSlot>() {

		@Override
		public int compare(TimeSlot t1, TimeSlot t2) {
			Time t1StartTime = t1.getStartTime();
			Time t2StartTimie = t2.getStartTime();
			if (t1StartTime.getHourOfDay() > t2StartTimie.getHourOfDay()) {
				return 1;
			} else if (t1StartTime.getHourOfDay() < t2StartTimie.getHourOfDay()) {
				return -1;
			} else {
				if (t1StartTime.getMinutes() > t2StartTimie.getMinutes()) {
					return 1;
				} else if (t1StartTime.getMinutes() < t2StartTimie.getMinutes()) {
					return -1;
				}
			}
			return 1;
		}
		
	};
	public static final Comparator<Position> SORT_BY_ASCENDING_NAME = new Comparator<Position>() {

		@Override
		public int compare(Position p1, Position p2) {
			String p1Name = p1.getName();
			String p2Name = p2.getName();
			return p1Name.compareTo(p2Name);
		}
		
	};
}
